from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app

import DebateApp

class NotFoundPageHandler(webapp.RequestHandler):
  def get(self):
    self.error(404)
    self.response.out.write('Not found.')

application = webapp.WSGIApplication(
  [
    ('/debate/admin/debates',         DebateApp.AdminDebates),             # Admin Gadget
    ('/debate/admin/debate/add',      DebateApp.AdminDebateAdd),           # Admin Gadget
    ('/debate/admin/indexes',         DebateApp.AdminIndexes),             # Admin Gadget
    ('/debate/admin/index/add',       DebateApp.AdminIndexAdd),            # Admin Gadget
    ('/debate/admin/participant/add', DebateApp.AdminIndexParticipantAdd), # Admin Gadget

    ('/debate/user/index',            DebateApp.UserIndex),                # Index Gadget

    ('/debate/debate/get',            DebateApp.DebateGet),                # Debate Gadget
    ('/debate/debate/edit',           DebateApp.DebateEdit),               # Debate Gadget
    ('/debate/debate/votes/get',      DebateApp.DebateVotesGet),           # Debate Gadget
    ('/debate/debate/vote',           DebateApp.DebateVote),               # Debate Gadget

    ('/debate/debate/roll',           DebateApp.DebateRollback),           #

    ('/debate/point/add',             DebateApp.PointAdd),                 # Debate/Point Gadget
    ('/debate/point/get',             DebateApp.PointGet),                 # Point Gadget
    ('/debate/point/edit',            DebateApp.PointEdit),                # Point Gadget
    ('/debate/point/rate',            DebateApp.PointRate),                # Point Gadget

    ('/debate/point/roll',            DebateApp.PointRollback),            #

    ('/debate/dump',                  DebateApp.DebDump),                  # Debug

    ('/debate/blip/rate',             DebateApp.BlipRate),                 # Blip Gadget

    ('/debate/export/debates',        DebateApp.ExportDebates),            # Export
    ('/debate/export/points',         DebateApp.ExportPoints),             # Export
    ('/debate/export/participants',   DebateApp.ExportParticipants),       # Export

    ('/debate/exchange/add',          DebateApp.ExchangeAdd),              # Exchanger
    ('/debate/exchange/get',          DebateApp.ExchangeGet),              # Exchanger
    ('/.*',                           NotFoundPageHandler)
  ], debug=True)

def main():
  run_wsgi_app(application)

if __name__ == "__main__":
  main()
